<template>
<div>
  <el-button type="info" @click="back">返回</el-button>
 <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      prop="selectid"
      label="选课学生学号"
      width="120">
    </el-table-column>
    <el-table-column
      prop="selectname"
      label="选课学生姓名"
      width="120">
    </el-table-column>
    <el-table-column
      prop="courseid"
      label="被选课程课程号"
      width="120">
    </el-table-column>
    <el-table-column
      prop="coursename"
      label="被选课程课程名"
      width="120">
    </el-table-column>
    <el-table-column
      prop="selectedtime"
      label="选课时间"
      width="300">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="edid(scope.row)" type="text" size="small">修改</el-button>
        <el-button @click="deleteid(scope.row)" type="text" size="small">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
 <el-paginationback
   background
  layout="prev, pager, next"
  page-size="6"
  :total="total"
  @current-change="page">
</el-paginationback>
</div>
</template>

<script>
import axios from 'axios'
export default {
  methods: {
    deleteid (row) {
      axios.delete(`http://localhost:8082/StudentManagement-Web/selectcourse/delete/${row.id}.json`).then(function (resp) { })
      alert('删除成功')
    },
    edid (row) {
      this.$router.push({
        path: '/Updata',
        query: {
          id: row.id
        }
      })
    },
    page (currentPage) {
      const _this = this
      axios.get(`http://localhost:8082/StudentManagement-Web/selectcourse/findall/${currentPage}/20.json`).then(function (resp) { _this.tableData = resp.data.content; _this.total = resp.data.totalElements })
    },
    back () {
      this.$router.replace('/Home')
    }
  },
  created () {
    const _this = this
    axios.get('http://localhost:8082/StudentManagement-Web/selectcourse/findall/1/20.json').then(function (resp) { _this.tableData = resp.data.content; _this.total = resp.data.totalElements })
  },
  data () {
    return {
      total: null,
      tableData: null
    }
  }
}
</script>
